import {defineStore} from "pinia";
import zjRequest from "@/services";
import {IActions, IState} from "@/store/globalModule/types";

const useGlobalModule = defineStore<any, IState, any, IActions>("globalStore", {
    state: () => ({}),
    actions: {
        // 获取验证码
        async getCaptchaAction() {
            return await zjRequest.get({
                url: "/captcha"
            })
        },
        // 上传图片
        async uploadFileAction(formData, timestamp) {
            const res = await zjRequest.post({
                url: "/upload",
                data: formData,
                needToken: true,
                needNavigate: "/my/edit"
            })
            if (res.code === 0) {
                return res.data
            } else {
                return null
            }
        }
    }
})
export default useGlobalModule